package com.bootdo.lgs.init;

import com.bootdo.common.config.ApplicationContextRegister;
import com.bootdo.common.model.BdConstant;
import com.bootdo.common.sms.model.SmsType;
import com.bootdo.common.sms.service.AliSms;
import com.bootdo.lgs.lgsInterfaces.blc.model.BlcTraceData;
import com.bootdo.lgs.lgsInterfaces.blc.service.BlcService;
import com.bootdo.lgs.lgsInterfaces.jzy.JzyLogisticsService;
import com.bootdo.lgs.lgsInterfaces.jzy.LoginInfo;
import com.bootdo.lgs.main.model.EvaluateRespond;
import com.bootdo.lgs.main.service.MainService;
import com.bootdo.lgs.main.service.impl.MainServiceImpl;
import com.bootdo.lgs.order.service.impl.OrderServiceImpl;
import com.bootdo.lgs.ordertrace.model.OrderTraceCondition;
import com.bootdo.lgs.ordertrace.model.OrderTraceQuery;
import com.bootdo.lgs.ordertrace.service.OrderTraceService;
import com.bootdo.system.domain.UserDO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Order(value = 1)
public class StartRunner implements CommandLineRunner {

    private static final Logger logger = LoggerFactory.getLogger(StartRunner.class);

    @Autowired
    private RedisTemplate redisTemplate;

    @Override
    public void run(String... strings) throws Exception {
        System.out.println("==========项目启动完成、开始初始化任务：===========");
//        OrderTraceService orderTraceService = ApplicationContextRegister.getBean(OrderTraceService.class);
//        OrderTraceCondition condition = new OrderTraceCondition();
//        condition.setCom("annengwuliu");
//        condition.setNum("300269633145");
//        condition.setOrderId(3l);
//        orderTraceService.refreshOrderTrace(condition);
//        System.out.println("==========跟踪信息刷新完成：===========");

//        AliSms aliSms  = ApplicationContextRegister.getBean(AliSms.class);
//        aliSms.send("13552531336,13687321336","", SmsType.XD_XCX_BIND,"{\"code\":\"123456\"}");
//        System.out.println("==========短信发送完成：===========");

//        BlcService blcService = ApplicationContextRegister.getBean(BlcService.class);
//        List<BlcTraceData> list = blcService.getTraceDataByOrderId("0092670");
//        System.out.println(list);
//        System.out.println("==========百路驰 跟踪信息刷新完成：===========");

//        OrderTraceService orderTraceService = ApplicationContextRegister.getBean(OrderTraceService.class);
//        OrderTraceQuery condition = new OrderTraceQuery();
//        condition.setOrderId(3l);
//        orderTraceService.getListFromDb(condition);
//
//        System.out.println("==========init 获取地址结束：===========");

//        System.out.println("==========查询统计开始：===========");
//        MainService mainService = ApplicationContextRegister.getBean(MainService.class);
//        UserDO condition = new UserDO();
//        List<EvaluateRespond> evaluateResponds =  mainService.getEvaluate(condition);
//        System.out.println(evaluateResponds);
//        System.out.println("==========查询统计结束：===========");

        System.out.println("==========redis缓存使用开始：===========");
        //RedisTemplate redisTemplate = ApplicationContextRegister.getBean(RedisTemplate.class);
        redisTemplate.opsForValue().set("gyw-test", "gywde test");
        logger.info("redis缓存key：gyw-test");
        String value = redisTemplate.opsForValue().get("gyw-test").toString();
        logger.info("redis获取key：[gyw-test]:" + value);
        System.out.println("==========redis缓存使用结束：===========");

//        System.out.println("==========今朝阳登陆接口调用开始：===========");
//        LoginInfo loginInfo = JzyLogisticsService.login();
//        System.out.println("登陆返回:"+loginInfo);
//        System.out.println("==========今朝阳登陆接口调用结束：===========");


    }

}
